﻿using System.Collections.Generic;
using BF3StatsNetApi;
using BF3StatsNetApi.BLL;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BF3StatsNetApiTest
{
    /// <summary>
    /// Summary description for BF3StatsNetApiUnitTest
    /// </summary>
    [TestClass]
    public class BF3StatsNetUnitTest
    {
        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        static BF3StatsNet _instance = null;

        [ClassInitialize]
        public static void ClassInitialize(TestContext testContext)
        {
            _instance = BF3StatsNet.Instance;
        }

        [ClassCleanup]
        public static void MyClassCleanup()
        {
            _instance = null;
        }


        /// <summary>
        /// Testing the GetPlayerInfo method of the BF3StatsNetApi.dll
        /// 
        /// The two calls is made to test the usage of the caching
        /// </summary>
        [TestMethod]
        public void TestGetPlayerInfo()
        {
            Player myPlayer = _instance.GetPlayerInfo("pc", "dthought");
            Assert.IsNotNull(myPlayer);

            Player myPlayer2 = _instance.GetPlayerInfo("pc", "DThought");
            Assert.IsNotNull(myPlayer2);
        }

        [TestMethod]
        public void TestGetPlayerList()
        {
            List<Player> players = _instance.GetPlayerList("pc","dthought,Zypher_CCL");
            Assert.IsNotNull(players);

            List<Player> players2 = _instance.GetPlayerList("pc", "DThought,zypher_ccl");
            Assert.IsNotNull(players);
        }
    }
}
